class JiraTool {

  bodyParser(data) {
    const ret = JSON.parse(data.body);
    return ret;
  };

  addParams(str, data) {
    for (let key in data) {
      let paramStr = `&${key}=${data[key]}`;
      paramStr = paramStr.replace(/\//g, '\\u002f')
      str += paramStr;
    }
    return str;
  }

  sortByKey(arr, key) {
    let ret = arr;
    for (var j = 0; j < ret.length - 1; j++) {
      for (var i = 0; i < ret.length - 1 - j; i++) {
        if (parseInt(ret[i][key]) < parseInt(ret[i + 1][key])) {
          var temp = ret[i];
          ret[i] = ret[i + 1];
          ret[i + 1] = temp;
        };
      };
    };
    return ret;
  };

};

module.exports = new JiraTool();